package
{
	import com.uyaer.wheel.Main;
	import com.uyaer.wheel.common.Common;
	import com.uyaer.wheel.common.Config;
	import com.uyaer.wheel.common.Platform;
	import com.uyaer.wheel.common.UserData;
	
	import flash.desktop.NativeApplication;
	import flash.desktop.SystemIdleMode;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import starling.core.Starling;
	
	[SWF(frameRate="30",backgroundColor="0x000000")]
	public class wheel extends Sprite
	{
		/**
		 *游戏菜单 
		 */		
		private var m_starling:Starling;
		/**
		 *主游戏窗口 
		 */		
		private var game:Starling;

		private var viewPort:Rectangle; //视窗
		public function wheel()
		{
			if(stage){
				onAdd();
			}else{
				addEventListener(Event.ADDED_TO_STAGE,onAdd);
			}
		}
		
		private function onAdd(e:Event = null):void{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
			
			initConfig();
			initCommon();
			loadUserData();
			
			viewPort = new Rectangle(0,0,Common.W,Common.H);
			m_starling = new Starling(Main,stage,viewPort);
			m_starling.start();
		}
		
		private function initConfig():void{
			Config.platform = Platform.MOBILE;
			Config.read();
		}
		
		private function loadUserData():void{
			UserData.me.read();
		}
		
		private function initCommon():void{
			Common.stage = stage;
			
			Common.W = stage.fullScreenWidth;
			Common.H = stage.fullScreenHeight;
			
			Common.S = Common.W / Config.BASIC_W;
		}
	}
}